import { Meta } from '@storybook/blocks';
import YouTubeVideoPlayer from '@/components/YouTubeVideoPlayer';
import * as AnimatedBuilderStories from '../stories/AnimatedBuilder.stories';

<Meta of={AnimatedBuilderStories} />

# AnimatedBuilder

A general-purpose widget for building animations.

<YouTubeVideoPlayer videoId="N-RiyZlv8v8" />

## Example

```dart liveslice=AnimatedBuilder height=400px
class Spinner extends StatefulWidget {
  @override
  _SpinnerState createState() => _SpinnerState();
}

class _SpinnerState extends State<Spinner> with SingleTickerProviderStateMixin {
  AnimationController _controller;

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(
      duration: const Duration(seconds: 10),
      vsync: this,
    )..repeat();
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return AnimatedBuilder(
      animation: _controller,
      child: Container(width: 200.0, height: 200.0, color: Colors.green),
      builder: (BuildContext context, Widget child) {
        return Transform.rotate(
          angle: _controller.value * 2.0 * math.pi,
          child: child,
        );
      },
    );
  }
}
```

## Related Links

- https://api.flutter.dev/flutter/widgets/AnimatedBuilder-class.html
- https://youtu.be/N-RiyZlv8v8
